package javaMSCRM;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.Border;

/**
 * @author Zoran IVANOV
 *
 */
public class Header extends JPanel{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	JavaMSCRM JavaMSCRM = null;

	/**
	 * @param JavaMSCRM
	 */
	public Header(JavaMSCRM JavaMSCRM) {
		this.JavaMSCRM = JavaMSCRM;
		this.setLayout(new BorderLayout(0,0));
		
		//Initialize Controls
		JavaMSCRM.HeaderBarContainer = new JPanel();
		JavaMSCRM.HeaderBarContainerTop = new JPanel();
		JavaMSCRM.HeaderBarContainerMiddle = new JPanel();
		JavaMSCRM.HeaderBarContainerBottom = new JPanel();
		JavaMSCRM.HeaderTitle = new JLabel("");
		JavaMSCRM.HeaderUserFullName = new JButton("");
		JavaMSCRM.SearchBarContainer = new JPanel();
		JavaMSCRM.SearchContainer = new JPanel();
		JavaMSCRM.SearchField = new JTextField(20);
		JavaMSCRM.SearchButton = new JButton("Search"); 
		JavaMSCRM.ViewFilterContainer = new JPanel();
		JavaMSCRM.ViewFilterJL = new JLabel("View: ");
		JavaMSCRM.ViewFilterJCB = new JComboBox();
	    JavaMSCRM.NewEntryJB = new JButton("New");
	    JavaMSCRM.DeleteEntryJB = new JButton("Delete");
	    JavaMSCRM.NewDeleteJP = new JPanel();
	    JavaMSCRM.MainMessage = new JLabel();
	    JavaMSCRM.MainMessage.setFont(new Font("Arial", Font.PLAIN, 11));
	    
		JavaMSCRM.HeaderBarContainerTop.setLayout(new BorderLayout(0,0));
		JavaMSCRM.HeaderBarContainerTop.setPreferredSize(new Dimension(200, 25));
		JavaMSCRM.HeaderTitle.setFont(new Font("Arial", Font.BOLD, 18));
		JavaMSCRM.HeaderTitle.setForeground(new Color(88,165,209));
		JavaMSCRM.HeaderBarContainerTop.add(JavaMSCRM.HeaderTitle, BorderLayout.LINE_START);
		JavaMSCRM.HeaderBarContainerTop.add(JavaMSCRM.HeaderUserFullName, BorderLayout.LINE_END);
		
		JavaMSCRM.HeaderUserFullName.setBackground(new Color(238,238,238));
		JavaMSCRM.HeaderUserFullName.setBorderPainted(false);
		JavaMSCRM.HeaderUserFullName.setForeground(new Color(88,165,209));
		JavaMSCRM.HeaderUserFullName.addActionListener(JavaMSCRM);
	    
		JavaMSCRM.SearchButton.setPreferredSize(new Dimension(80, 20));
		JavaMSCRM.SearchContainer.add(JavaMSCRM.SearchField);
		JavaMSCRM.SearchContainer.add(JavaMSCRM.SearchButton);
		JavaMSCRM.SearchContainer.setVisible(false);
		
		JavaMSCRM.HeaderBarContainerMiddle.setLayout(new BorderLayout(0,0));
		JavaMSCRM.HeaderBarContainerMiddle.setPreferredSize(new Dimension(200, 32));
		JavaMSCRM.HeaderBarContainerMiddle.add(JavaMSCRM.SearchContainer, BorderLayout.LINE_START);

		JavaMSCRM.ViewFilterJCB.setPreferredSize(new Dimension(200, 20));
		JavaMSCRM.ViewFilterContainer.add(JavaMSCRM.ViewFilterJL);
		JavaMSCRM.ViewFilterContainer.add(JavaMSCRM.ViewFilterJCB);
		JavaMSCRM.ViewFilterContainer.setVisible(false);
		
		JavaMSCRM.HeaderBarContainerMiddle.add(JavaMSCRM.ViewFilterContainer, BorderLayout.LINE_END);
		Border blackline = BorderFactory.createMatteBorder(1, 0, 1, 0, Color.gray);
		JavaMSCRM.HeaderBarContainerMiddle.setBorder(blackline);
		JavaMSCRM.HeaderBarContainerMiddle.setVisible(false);
		
		JavaMSCRM.HeaderBarContainerBottom.setLayout(new BorderLayout(0,0));
		JavaMSCRM.NewEntryJB.setPreferredSize(new Dimension(70, 20));
		JavaMSCRM.DeleteEntryJB.setPreferredSize(new Dimension(70, 20));
		JavaMSCRM.NewDeleteJP.setLayout(new FlowLayout(FlowLayout.LEFT));
		JavaMSCRM.NewDeleteJP.add(JavaMSCRM.NewEntryJB);
		JavaMSCRM.NewDeleteJP.add(JavaMSCRM.DeleteEntryJB);
		JavaMSCRM.NewEntryJB.setVisible(false);
		JavaMSCRM.DeleteEntryJB.setVisible(false);
				
		JavaMSCRM.HeaderBarContainerBottom.add(JavaMSCRM.NewDeleteJP, BorderLayout.LINE_START);
		JavaMSCRM.HeaderBarContainerBottom.add(JavaMSCRM.MainMessage, BorderLayout.LINE_END);
		
	    
		add(JavaMSCRM.HeaderBarContainerTop, BorderLayout.NORTH);
		add(JavaMSCRM.HeaderBarContainerMiddle, BorderLayout.CENTER);
		add(JavaMSCRM.HeaderBarContainerBottom, BorderLayout.SOUTH);
	}
}
